<template>
  <view v-if="sessionId" class="img-code">
  {{sessionId}}
    <image class="imgCode" :src="imgSrc" @click="refresh" />
  </view>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
import { getUrl } from "@/utils/source";

const { mapState } = createNamespacedHelpers("account");

export default {
  computed: {
    ...mapState(["sessionId"]),
  },
  created() {
    this.setImgUrl();
  },
  data() {
    return {
      imgSrc: "",
    };
  },
  methods: {
    setImgUrl() {
      this.imgSrc = `${getUrl("/member/index/get-capture")}&session-id=${
        this.sessionId
      }&v=${Date.now()}`;
    },
    refresh() {},
  },
};
</script>

<style lang="scss" scoped>
.img-code {
  display: flex;
  flex-wrap: nowrap;
}

.imgCode {
  width: 144rpx;
  height: 56rpx;
}
</style>
